home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
oocs
/
cservera.cls
< prev
next >
Wrap
Text File
|
1999-09-06
|
5KB
|
179 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cServerActions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
' access to the methods of the cFileActions class
Dim File As cFIleActions
' access to the methods of the cSysInfo class
Dim Sys As cSysInfo
' --- Events
Public Event ConnectionClosed()
Public Event RequestedID(Accepted As Boolean)
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'
' P U B L I C M E T H O D S
'
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Sub InitTCP(Port As Long, Server As Winsock)
' connect to the port
Server.LocalPort = Port
' Listen for incoming data
Server.Listen
End Sub
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Sub HandleIncomingData(sIncoming As String, Server As Winsock, SrvForm As Form)
'
Dim sCommand As String
Dim sIncomingData As String
'--- when a command is sent the first seperater is a comma, the default.
'--- Therefore "sDivider" is not set.
' Extract the command from the Left
' of the comma (default divider)
sCommand = EvalData(sIncoming, 1)
' extract the data being sent from the
' right of the comma (default divider)
sIncomingData = EvalData(sIncoming, 2)
' decide what command has been issued
Select Case sCommand
Case "Msg"
File.DisplayMsg sIncomingData
Case "SysInfo"
Sys.GetSysInfo
Case "GetFilePaths"
File.GatherFiles sIncomingData, SrvForm
End Select
End Sub
Sub Closed(Server As Winsock)
'Socket got a close call so close it if it's not already closed
If Server.State <> sckClosed Then Server.Close
'Call the form load event to reset all paramteres
Set File = Nothing
Set Sys = Nothing
RaiseEvent ConnectionClosed
End Sub
Sub ConnectReq(ByVal requestID As Long, Server As Winsock)
On Error GoTo IDERROR
If Server.State <> sckClosed Then Server.Close ' close Connection
Server.Accept requestID 'Make the connection
RaiseEvent RequestedID(True)
Exit Sub
IDERROR:
RaiseEvent RequestedID(False)
End Sub
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'======================================================================
' (EvalData Function)
'
' Purpose - Extract data from a given string, to the right or left
' of a specified character.
'
' Parameters:
' sIncoming - The String you want to extract data from.
' iRtLt - Extract from the Left, 1.
' Extract from the right, 2.
' sDivider - The character that seperates the data in
' the string. <default = ",">
'
' Returns:
' (type)String
' Returns the data to the right or left of strDivider.
'======================================================================
Private Function EvalData(sIncoming As String, iRtLt As Integer, _
Optional sDivider As String) As String
Dim i As Integer
Dim TempStr As String
' Storage for the current Divider
Dim sSplit As String
' the current character used to divide the data
If sDivider = "" Then
sSplit = ","
Else
sSplit = sDivider
End If
' getting the right or left?
Select Case iRtLt
Case 1
' remove the data to the Left of the Current Divider
For i = 0 To Len(sIncoming)
TempStr = Left(sIncoming, i)
If Right(TempStr, 1) = sSplit Then
EvalData = Left(TempStr, Len(TempStr) - 1)
Exit Function
End If
Next
Case 2
' remove the data to the Right of the Current Divider
For i = 0 To Len(sIncoming)
TempStr = Right(sIncoming, i)
If Left(TempStr, 1) = sSplit Then
EvalData = Right(TempStr, Len(TempStr) - 1)
Exit Function
End If
Next
End Select
End Function
Private Sub Class_Initialize()
' create objects to access the file and system
' retrieval methods
Set File = New cFIleActions
Set Sys = New cSysInfo
End Sub